//win includes from mForms
//implementation
uses Windows;
const WndClassName = 'MinCL_Window_Class_';
var  WndClassNum:integer;

procedure TApplication.ProcessMessages;
var
  AMSG:TMsg;
begin
  GetMessage(PMSG(@AMSG)^,0,0,0);
  //if AMSG.message=WM_PAINT then writeln('paint sent via queue');
  TranslateMessage(PMSG(@AMSG)^);
  DispatchMessage(PMSG(@AMSG)^);
end;
procedure TForm.SetCaption(AValue: AnsiString);
begin
  inherited SetCaption(AValue);
  if FHandle=0 then exit;
  SetWindowText(Handle,@AValue[1]);
end;

constructor TForm.Create(AOwner: TComponent);
var WCls:TWNDCLASS;
begin
  inherited Create(AOwner);
  FSpecificHandling:=true;
  AllWnds.Add(self);
  if FWidth=0 then FWidth:=100;
  if FHeight=0 then FHeight:=100;
  inc(WndClassNum);//Doing this BEFORE real usage might be safer
  FFormExtData:=WndClassName+IntToStr(WndClassNum-1);
  WCls.style:=CS_HREDRAW or CS_VREDRAW or CS_DBLCLKS;
  WCls.lpfnWndProc:=@AllWndProc;
  Wcls.cbClsExtra:=0;
  WCls.cbWndExtra:=0;
  WCls.hInstance:=HINSTANCE;
  WCls.hIcon:=0;
  wcls.hCursor:=0;
  wcls.hbrBackground:=COLOR_BTNFACE;
  WCls.lpszMenuName:=nil;
  WCls.lpszClassName:=@FFormExtData[1];
  RegisterClass(WCls);
  if FCaption='' then FCaption:=' ';
  FHandle:=CreateWindow(@FFormExtData[1],@Caption[1],WS_BORDER or WS_CAPTION or WS_MAXIMIZEBOX
    or WS_MINIMIZEBOX or WS_SYSMENU or WS_SIZEBOX,FLeft,FTop,FWidth,FHeight,
    0,0,HINSTANCE,nil);
end;


destructor TForm.Destroy;
begin
  UnregisterClass(@FFormExtData[1],HINSTANCE);
  inherited Destroy;
end;

var CLS:TWNDCLASS;
procedure PlatformInit_mForms;{$ifdef FPC}inline;{$endif}
begin

  WndClassNum:=0;
  while LongInt(GetClassInfo(HINSTANCE,PChar(WndClassName+IntToStr(WndClassNum)),cls))<>0 do
    Inc(WndClassNum);
end;
